$(document).ready(function() {
    var animateSub = $('#subscribe-div');
	var subLine = $('#subscribe-line');
    var test = false;
    var panelWidth = 25;
    var maxShift = 250;
    var speed = 1;
    var position = 25;
    var right = 0;
    
    subLine.click(function() {
        var frame = function(direction, shift) {
            position = (direction * (right += 2.5) + shift);
            animateSub.css('width', position + 'px');		
            if (right == maxShift) {			
                clearInterval(timer);
                right = 0;
                test = !test;
            }
        };		
        if ((position == panelWidth) || (position == panelWidth + maxShift)) {		
            if (!test) {    
                var timer = setInterval(function(){ frame(1, panelWidth); }, speed);	
            } else {		
                var timer = setInterval(function(){ frame(-1, panelWidth + maxShift); }, speed);
            }
        }    
    });	
});